/*
 * INET		An implementation of the TCP/IP protocol suite for the LINUX
 *		operating system.  INET is implemented using the  BSD Socket
 *		interface as the means of communication with the user level.
 *
 *		Global definitions for the IP router interface.
 *
 * Version:	@(#)route.h	1.0.3	05/27/93
 *
 * Authors:	Original taken from Berkeley UNIX 4.3, (c) UCB 1986-1988
 *		Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
 *
 *		This program is free software; you can redistribute it and/or
 *		modify it under the terms of the GNU General Public License
 *		as published by the Free Software Foundation; either version
 *		2 of the License, or (at your option) any later version.
 */
#ifndef _LINUX_ROUTE_H
#define _LINUX_ROUTE_H

#include <linux/if.h>

/* 
	rentry，old_rentry 只用于用户空间和内核空间传输参数，内核路由表项
	并非使用这两个结构表示，而是由 rtable 结构表示一个路由表项
	rentry，old_rentry 这个结构主要用于选项设置或获取。即通过这两个结构传送
	参数更改或者获取系统路由表项内容。
*/

/* This structure gets passed by the SIOCADDRTOLD and SIOCDELRTOLD calls. */
struct old_rtentry {
	unsigned long	rt_genmask;	// 路由表项 IP 地址网络掩码
	struct sockaddr	rt_dst;	// 该字段在进行路由时与数据包目的地址进行匹配。
	struct sockaddr	rt_gateway;	// 中间网关（或路由器）地址，当无法直接到达目的地时，需要经过网关进行转发，此为中间网关的地址
	short		rt_flags;	// 路由表项所处状态标志位
	short		rt_refcnt;	// 该路由表项的使用计数
	unsigned long	rt_use;	// 该路由表项是否正在使用
	char		*rt_dev; 	// 该路由路径的出站接口设备
};

/* This structure gets passed by the SIOCADDRT and SIOCDELRT calls. */
struct rtentry {
	unsigned long	rt_hash;	/* hash key for lookups		*/
	struct sockaddr	rt_dst;		/* target address		*/
	struct sockaddr	rt_gateway;	/* gateway addr (RTF_GATEWAY)	*/
	struct sockaddr	rt_genmask;	/* target network mask (IP)	*/
	short		rt_flags;
	short		rt_refcnt;
	unsigned long	rt_use;
	struct ifnet	*rt_ifp;
	short		rt_metric;	/* +1 for binary compatibility!	*/
	char		*rt_dev;	/* forcing the device at add	*/
	unsigned long	rt_mss;		/* per route MTU/Window */
	/* 该路由表项所代表路径的窗口大小。窗口是一种限制数据包发送过快的措施。发送数据包的
个数或总字节数应该在窗口内。 */
	unsigned long	rt_window;	/* Window clamping */
};


#define	RTF_UP		0x0001		/* route usable	该表项可被使用	  */
#define	RTF_GATEWAY	0x0002		/* destination is a gateway	 该表项通向一个路由器或者网关 */
#define	RTF_HOST	0x0004		/* host entry (net otherwise)	该表项提供可直达目的主机的路径  */
/* 该表项超时后已进行重新确认。每个路由表项(除了永久表项)都有一个超时时间，当超时发
生时，该表项必须经过重新确认，方才认为有效。 */
#define RTF_REINSTATE	0x0008		/* reinstate route after tmout	  */
/* 该表项是根据接收的数据包信息动态建立的，且内容可变。如 ICMP 送来一个 Redirect 信息，
可表项表示的路径可被更改 */
#define	RTF_DYNAMIC	0x0010		/* created dyn. (by redirect)	  */
#define	RTF_MODIFIED	0x0020		/* modified dyn. (by redirect)	 该表项内容根据 ICMP Redirect 信息进行了更改。 */
#define RTF_MSS		0x0040		/* specific MSS for this route	该表项指定了最大传输单元。数据包大小必须满足该规定。  */
#define RTF_WINDOW	0x0080		/* per route window clamping	窗口大小  */

/*
 *	REMOVE THESE BY 1.2.0 !!!!!!!!!!!!!!!!!
 */
 
#define	RTF_MTU		RTF_MSS
#define rt_mtu		rt_mss		

#endif	/* _LINUX_ROUTE_H */
